﻿/*
 * Created by SharpDevelop.
 * User: user
 * Date: 07/09/2011
 * Time: 15:55
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Collections.Generic;

namespace csharp.rad.lavanderia.classes
{
	/// <summary>
	/// Description of Service.
	/// </summary>
	public class Service : csharp.rad.lavanderia.classes.original.T_Service
	{
		public Service()
		{
		}
		
		public override void setGsql()
		{
			gsql.setValue(Convert.ToDateTime(_date).ToString(common.CONSTANTS.dateFormatInternationalSqlite),"service_date");			
			base.setGsql();
		}
		
		public override void get(System.Data.DataRow dr)
		{
			_date= Convert.ToDateTime(dr["service_date"]).ToString(common.CONSTANTS.dateFormatBrazilian);			
			base.get(dr);
		}
	}
	
	public class Services : csharp.rad.lavanderia.classes.original.T_Services
	{
		public Services()
		{
			
		}
		
		public Service get(int index)
		{
			return (Service)items[index];
		}
		
		
		public Service get()
		{
			return get(index);
		}

		public int getMaxNumber()
		{
			gsql.prepare();
			List<string> aux= new List<string>();
			aux.Add("MAX(service_number) AS number");
			
			gsql.setFieldsName(aux);
			gsql.execute();
			if( gsql.getRowCount() > 0)
				return Convert.ToInt32(gsql.getRow(0)["number"]);
			return 1;
		}
	}
}
